#coding=utf-8

# Django settings for {{ project_name }} project.

import os

TEMPLATE_DEBUG = DEBUG = True

MANAGERS = ADMINS = (
     ('etng', 'etng2004@gmail.com'),
)

TIME_ZONE = 'Asia/Chongqing'

LANGUAGE_CODE = 'zh-cn'

SITE_ID = 1

USE_I18N = True

SITE_ROOT = os.path.dirname(os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')

if DEBUG:
    DATABASE_ENGINE = 'sqlite3'
    DATABASE_NAME = os.path.join(SITE_ROOT, '{{ project_name }}.db')
    SITE_URL = 'http://localhost:8000/'
else:
    SITE_URL = 'http://www.{{ project_name }}.com/'
    DATABASE_NAME = '{{ project_name }}'
    DATABASE_ENGINE = 'mysql'
    DATABASE_USER = 'username'
    DATABASE_PASSWORD = 'password'
    DATABASE_HOST = ''
    DATABASE_PORT = ''
    CACHE_BACKEND = "file://" + os.path.join(SITE_ROOT, 'var', 'cache')
    #CACHE_BACKEND = "memcached://127.0.0.1:11211/"
    CACHE_TIMEOUT = 60*5

MEDIA_URL = SITE_URL + 'media/'
ADMIN_MEDIA_PREFIX = SITE_URL + 'media/admin/'

SECRET_KEY = ''

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
    'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.CacheMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.doc.XViewMiddleware',
    'middleware.threadlocals.ThreadLocals',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = 'urls'

TEMPLATE_DIRS = (
    os.path.join(SITE_ROOT, 'templates'),
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
#   uncomment the folling line to login with  email or username
#    'utils.django.auth_backends.EmailOrUsernameModelBackend',
)
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.flatpages',
##  '{{ project_name }}.apps.syntax_colorize',
)

# use gmail for mail sender
# copy from http://nathanostgard.com/archives/2007/7/2/gmail_and_django/
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '{{ project_name }}_mailer@gmail.com'
EMAIL_HOST_PASSWORD = 'change_this_to_{{ project_name }}_mailer''s password'
EMAIL_PORT = 587

from utils import logs
LOG = logs.getLogger("settings", outfile="var/log/{{ project_name }}.log:10000000:5", level={'root': DEBUG and logs.DEBUG or logs.ERROR, 'caching': logs.INFO})
if DEBUG:
    LOG.debug("settings loaded!")
